package com.jeeplus.test.jlnu.tableManage.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeeplus.test.jlnu.tableManage.domain.entity.JlnuTableManage;
import com.jeeplus.test.jlnu.tableManage.domain.query.TableManageQuery;
import com.jeeplus.test.jlnu.tableManage.service.JlnuTableManageService;
import com.jeeplus.test.tools.resp.R;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.*;

/**
 * 动态表头(JlnuTableManage)表控制层
 *
 * @author ChiHongYu
 * @since 2025-02-17 15:16:26
 */
@Api(tags = "动态表头接口")
@Slf4j
@RestController
@RequestMapping("/tableManage")
public class JlnuTableManageController {
    
    @Resource
    private JlnuTableManageService jlnuTableManageService;
    
    
    @ApiOperation("创建|修改")
    @PostMapping("insertOrUpdate")
    public R create(@RequestBody TableManageQuery param) {
        boolean opResult = this.jlnuTableManageService.insertOrUpdate(param);
        if (opResult){
            return R.suc();
        }else{
            return R.error().setMsg("创建失败，请联系管理员");
        }
    }

    
    @ApiOperation("查询详情")
    @GetMapping("get")
    public R get(@RequestParam("id") Integer id) {
        JlnuTableManage jlnuTableManage = this.jlnuTableManageService.queryById(id);
        return R.suc(jlnuTableManage);
    }

    @ApiOperation("查询详情")
    @GetMapping("getByOffice")
    public R getByOffice(@RequestParam("officeId") String officeId,
                         @RequestParam("type") String type) {
        JlnuTableManage jlnuTableManage = this.jlnuTableManageService.getByOffice(officeId,type);
        return R.suc(jlnuTableManage);
    }

    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value = "主键",required = true,dataType = "String",paramType = "query")
    })
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "接口返回成功状态"),
            @ApiResponse(code = 201, message = "接口返回失败状态"),
            @ApiResponse(code = 500, message = "接口返回未知错误，请联系开发人员调试")
    })
    @ApiOperation(value = "删除",notes = "访问此接口，返回操作结果")
    @GetMapping("del")
    public R del(@RequestParam int id) {
        return null;
        /*boolean opResult = this.jlnuTableManageService.deleteById(id);
        if (opResult){
            return R.suc();
        }else{
            return R.error();
        }*/
    }

}
